<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>可以从外部关闭的下拉菜单</title>
    <link rel="stylesheet" href="style.css" type="text/css">
  </head>
  <body>
    <div id="app" v-cloak>
      <div class="main" v-clickoutside="handleClose">
        <button @click="show=!show">点击显示下拉菜单</button>
        <div class="dropdown" v-show="show">
          <p>下拉框的内容，点击外面区域可以关闭</p>
        </div>
      </div>
    </div>
    <script src="https://unpkg.com/vue/dist/vue.min.js"></script>
    <script src="clickoutside.js"></script>
    <script type="text/javascript">
      var app = new Vue({
        el: '#app',
        data: {
          show: false
        },
        methods: {
          handleClose() {
            this.show = false;
          }
        },
      })
    </script>
  </body>
</html>